

package vistas;

import controladores.CListadoVendido;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTable;
import modelos.MTabla;


public class VListadoVendido extends javax.swing.JFrame {
private Vector<JButton> boton;
    private CListadoVendido control;
    private MTabla modeloTabla;
    private Vector<String> fila;
    private VProductoMas producto;
    /** Creates new form ListadoIngrediente */
    public VListadoVendido() {
        initComponents();
        modeloTabla= new MTabla();
        boton = new Vector<JButton>();
        fila= new Vector<String>();
        control = new  CListadoVendido(this);
        producto = new VProductoMas();
        tblIngrediente.setModel(modeloTabla);
        fila.add("Ingredientes");
        fila.add("Porciones");
        modeloTabla.setColumnIdentifiers(fila);
        modeloTabla.addRow(fila);
        boton.add(btnSalir);
        boton.add(btnConsultar);
        boton.add(btnCancelar);
        boton.add(btnMostrar);

        for (int i = 0; i < boton.size(); i++)
            boton.elementAt(i).addActionListener(control);
        rbtnAsces.addActionListener(control);
        rbtnDesces.addActionListener(control);
    }

    public void mostrarProductos(Vector<String> v){
        producto.mostrarInfo(v);
    }


    public JLabel getLblIngrediente() {
        return lblIngrediente;
    }


    public JTable getTblIngrediente() {
        return tblIngrediente;
    }

     public void agregarFila(String[] v){
    	
        fila = new Vector<String>();
        for (int i = 0; i < v.length; i++)
            fila.add(v[i]);
        modeloTabla.addRow(fila);
    }

    public void reiniciar() {
        modeloTabla.setRowCount(0);
    }


    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

	buttonGroup1 = new javax.swing.ButtonGroup();
        lblIngrediente = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tblIngrediente = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        rbtnAsces = new javax.swing.JRadioButton("Asces");
        rbtnDesces = new javax.swing.JRadioButton("Desces");
        btnConsultar = new javax.swing.JButton("Consultar");
        btnCancelar = new javax.swing.JButton("Cancelar");
        btnSalir = new javax.swing.JButton("Salir");
	btnMostrar = new javax.swing.JButton("Mostrar");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(null);

        lblIngrediente.setFont(new java.awt.Font("Arial", 0, 15));
        getContentPane().add(lblIngrediente);
        lblIngrediente.setBounds(520, 40, 300, 30);

        tblIngrediente.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane3.setViewportView(tblIngrediente);

        getContentPane().add(jScrollPane3);
        jScrollPane3.setBounds(30, 100, 490, 270);
        jScrollPane3.setBackground(new java.awt.Color(255,255,255));

        rbtnAsces.setFont(new java.awt.Font("Ubuntu", 1, 15));
        rbtnAsces.setText("Ascendentemente");
        getContentPane().add(rbtnAsces);
        rbtnAsces.setBounds(163, 50, 190, 22);
        rbtnAsces.setBackground(new java.awt.Color(255,255,255));

        rbtnDesces.setFont(new java.awt.Font("Ubuntu", 1, 15));
        rbtnDesces.setText("Descendentemente");
        getContentPane().add(rbtnDesces);
        rbtnDesces.setBounds(355, 50, 190, 22);
        rbtnDesces.setBackground(new java.awt.Color(255,255,255));

        jLabel1.setFont(new java.awt.Font("Ubuntu", 1, 15));
        jLabel1.setText("Forma de Ordenar");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(8, 40, 160, 40);

        jLabel4.setFont(new java.awt.Font("Ubuntu", 1, 15));
        jLabel4.setText("Listado de Productos Mas Vendidos");
        getContentPane().add(jLabel4);
        jLabel4.setBounds(150, 10, 280, 30);

        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel1.setLayout(null);

        btnConsultar.setFont(new java.awt.Font("Ubuntu", 1, 15));
        btnConsultar.setText("Consultar");
        jPanel1.add(btnConsultar);
        btnConsultar.setBounds(10, 20, 120, 30);

        btnCancelar.setFont(new java.awt.Font("Ubuntu", 1, 15));
        btnCancelar.setText("Cancelar");
        jPanel1.add(btnCancelar);
        btnCancelar.setBounds(10, 70, 120, 30);

        btnSalir.setFont(new java.awt.Font("Ubuntu", 1, 15));
        btnSalir.setText("Salir");
        jPanel1.add(btnSalir);
        btnSalir.setBounds(140, 70, 120, 30);

        btnMostrar.setFont(new java.awt.Font("Ubuntu", 1, 15));
        btnMostrar.setText("Mostrar ");
        jPanel1.add(btnMostrar);
        btnMostrar.setBounds(140, 20, 120, 30);

        getContentPane().add(jPanel1);
        jPanel1.setBounds(140, 390, 270, 120);
        jPanel1.setBackground(new java.awt.Color(255,255,255));

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        this.setBounds(0, 0, 549, 554);
        getContentPane().setBackground(new java.awt.Color(14,151,255));
    }// </editor-fold>//GEN-END:initComponents

 

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VListadoVendido().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnConsultar;
    private javax.swing.JButton btnMostrar;
    private javax.swing.JButton btnSalir;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JLabel lblIngrediente;
    private javax.swing.JRadioButton rbtnAsces;
    private javax.swing.JRadioButton rbtnDesces;
    private javax.swing.JTable tblIngrediente;
    // End of variables declaration//GEN-END:variables

    public void mostrar(Vector<String> v) {
        VProductoMas as = new VProductoMas();
        as.mostrarInfo(v);
        as.setVisible(true);
        as.show();
    }

}
